package com.ctshk.app.certificate.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.certificate.dto.CertificateMacauTravelDTO;
import com.ctshk.rpc.certificate.req.CertificateMacauTravelReq;
import com.ctshk.rpc.certificate.req.ProcCommonCertificateReq;
import com.ctshk.rpc.certificate.req.QueryAppointmentInfoReq;
import com.ctshk.rpc.certificate.service.ICertificateMacauTravelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 赴澳门个人旅游签注 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-25
 */
@Api(value = "赴澳门个人旅游签注",tags = "赴澳门个人旅游签注")
@RestController
@RequestMapping("/certificate-macau-travel")
public class CertificateMacauTravelController extends BaseController {

    @DubboReference
    private ICertificateMacauTravelService travelService;

    @ApiOperation(value = "赴澳门个人旅游签注登记", notes = "赴澳门个人旅游签注登记")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.ADD, operTitle = "赴澳门个人旅游签注登记", operDesc = "赴澳门个人旅游签注登记")
    @PostMapping("/save")
    public Result saveMacauTravel(@RequestBody @Valid CertificateMacauTravelReq certificateMacauTravelReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return travelService.saveMacauTravel(certificateMacauTravelReq, userId);
    }

    @ApiOperation(value = "赴澳门个人旅游签注信息详情", notes = "赴澳门个人旅游签注信息详情")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询证件信息详情", operDesc = "查询证件信息详情")
    @GetMapping(value = "/detail")
    public Result<CertificateMacauTravelDTO> queryDetail(@RequestParam(value = "id") Long id) {
        return Result.success(travelService.queryDetail(id));
    }

    @ApiOperation(value = "修改赴澳门个人旅游签注信息", notes = "修改赴澳门个人旅游签注信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "修改证件信息", operDesc = "修改证件信息")
    @PostMapping("/update")
    public Result updateMacauTravel(@RequestBody @Valid CertificateMacauTravelReq certificateMacauTravelReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return travelService.updateMacauTravel(certificateMacauTravelReq, userId);
    }

    @ApiOperation(value = "处理赴澳门个人旅游签注预约信息", notes = "处理赴澳门个人旅游签注预约信息")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.UPDATE, operTitle = "处理赴澳门个人旅游签注预约信息", operDesc = "处理赴澳门个人旅游签注预约信息")
    @PostMapping("/proc-reserve")
    public Result procReserveMacauTravel(@RequestBody @Valid ProcCommonCertificateReq procReserveMacauTravelReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return travelService.procReserveMacauTravel(procReserveMacauTravelReq, userId);
    }

    @ApiOperation(value = "预约信息(核对, 完成预约, 查询预约状态结果)", notes = "预约信息(核对, 完成预约, 查询预约状态结果)")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "查询预约信息", operDesc = "查询预约信息")
    @GetMapping(value = "/query-appointment-info")
    public Result<CertificateMacauTravelDTO> queryAppointmentInfo(@RequestBody @Valid QueryAppointmentInfoReq queryAppointmentInfoReq) {
        Long userId = getCurrentUser(getRequest()).getId();
        return travelService.queryAppointmentInfo(queryAppointmentInfoReq, userId);
    }

    @ApiOperation(value = "取消预约", notes = "取消预约")
    @OperationLogAnnotation(operModul = OperationLogModel.TICKET, operType = OperationLogType.QUERY, operTitle = "取消预约", operDesc = "取消预约")
    @GetMapping(value = "/cancel-appointment")
    public Result cancelAppointment(@RequestParam(value = "id") Long id) {
        Long userId = getCurrentUser(getRequest()).getId();
        return travelService.cancelAppointment(id, userId);
    }

}
